<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="content-style-type" content="text/css">
<link rel="stylesheet" type="text/css" href="style.css">
<title>DexGuard Ant Build</title>
</head>
<body>

<script type="text/javascript" language="JavaScript">
<!--
if (window.self==window.top)
  document.write('<a target="_top" href="index.html#antbuild.html" class="largebutton">DexGuard index</a>')
//-->
</script>
<noscript>
<a target="_top" href="index.html#antbuild.html" class="largebutton">DexGuard index</a>
</noscript>

<h2>Ant Build</h2>

<b>DexGuard</b> can be integrated in the Ant build process of the Android
SDK Tools (revision 21.0.0 or higher).

<h3>Setting up the Ant build</h3>

You can enable DexGuard in the Android Ant build as follows:
<ol>
<li>Copy the two configuration files from DexGuard's <code>ant</code>
    directory to the main directory of your Android project:
<pre>
dexguard-project.txt
custom_rules.xml
</pre></li>
<li>Specify the main DexGuard directory on your system in the configuration
    file <code>local.properties</code> in your Android project. For instance:
<pre>
dexguard.dir=/usr/local/DexGuard5.0
</pre></li>
</ol>

The standard Ant build process will now automatically use DexGuard's Ant task
for your Android project. You'll see this in the build process:
the lines with <code>[dexguard]</code> in the console replace all lines with
<code>[proguard]</code>, <code>[dex]</code>, <code>[dx]</code>,
<code>[apkbuilder]</code>, <code>[signjar]</code>, and
<code>[zip-align]</code>.
<p>

DexGuard is most commonly applied to final <b>application projects</b>. This
is the easiest and most effective approach, since it processes the combined
code in a single step.
<p>

DexGuard can also be applied to <b>library projects</b>, if the library jar is
the final product. You should then take some care with class encryption, as
discussed for the <a href="usage.html#encryptclasses">class encryption
option</a>. Furthermore, tamper detection is only supported if the final
application is also built and packaged using DexGuard.
<p>

You can find examples of working projects in the directory <code>samples</code>.

<h3>Building</h3>

The procedure for building Android applications and libraries remains the same.
You can invoke <code>ant</code> with the usual targets, such as
<code>debug</code> and <code>release</code>. For instance, to build the release
version of your application and install it on a connected device:
<pre>
ant release install
</pre>

Debug builds use debug settings, without optimization or obfuscation. Release 
builds use release settings, with full optimization and obfuscation.
Applications can optionally be signed. The entries in application archives 
are always zip-aligned for efficiency.
<p>

The Ant build picks up custom configurations from the following optional files
in your Android project:
<pre>
dexguard-project.txt         (for all targets)
dexguard-project-debug.txt   (for target 'debug')
dexguard-project-release.txt (for target 'release')
proguard-project.txt         (for backward compatibility with ProGuard)
</pre>

The default version of the first file contains a number of settings that can
be enabled to perform string encryption, class encryption, and to hide access
to sensitive APIs.

<h3>Further tips</h3>

As before, you can specify some useful properties in the Ant configuration
file <code>local.properties</code>:
<ul class="spacious">
<li>If you want to get verbose output for the entire build process, including
    DexGuard, you can add this line:
<pre>
verbose = true
</pre></li>
<li>If you want to sign your application, you can specify all or some of the
    necessary properties in the file <code>local.properties</code> of your
    Android project. For example:
<pre>
key.store          = /home/user/.android/debug.keystore
key.store.password = android
key.alias          = androiddebugkey
key.alias.password = android
</pre>
If you don't specify passwords, the build process will ask for them.</li>
</ul>

<h3>Reverting to the traditional Ant build</h3>

You can go back to the basic Ant build of the Android SDK by removing or
renaming the custom rules file <code>custom_rules.xml</code> in the main
directory of your Android project.

<hr />
<address>
Copyright &copy; 2002-2014
<a target="other" href="http://www.saikoa.com/">Saikoa BVBA</a>.
</address>
</body>
</html>
